import path from 'node:path'
import Vue from '@vitejs/plugin-vue'

// import Unocss from 'unocss/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import Components from 'unplugin-vue-components/vite'
// import VueRouter from 'unplugin-vue-router/vite'
import AutoImport from 'unplugin-auto-import/vite';
import { defineConfig } from 'vite'
import vueJsx from '@vitejs/plugin-vue-jsx';

// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    alias: {
      '@/': `${path.resolve(__dirname, 'src')}/`,
    },
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@use "@/styles/element/theme.scss" as *;`,
      },
    },
  },

  plugins: [
    Vue(),
    vueJsx(),
    // https://github.com/posva/unplugin-vue-router
    /*VueRouter({
      extensions: ['.vue', '.md'],
      dts: 'src/typed-router.d.ts',
    }),*/
    AutoImport({
      // 安装两行后你会发现在组件中不用再导入ref，reactive等
      imports: ["vue", "vue-router"],
      //存放的位置
      eslintrc: {
        enabled: false,
        filepath: "./.eslintrc-auto-import.json",
        globalsPropValue: true,
      },
      vueTemplate: true,
      // 配置文件生成位置(false:关闭自动生成)
      // dts: false,
      dts: 'src/auto-imports.d.d.ts',
    }),
    Components({
      resolvers: [
        ElementPlusResolver({
          importStyle: 'sass', // 要设置，否则主题色覆盖不生效（有些版本不需要，可能高版本需要了）
        }),
      ],
      dirs: [],
      dts: 'src/components.d.ts',
    }),
  ],
})
